﻿@model IEnumerable<SuperJ.CMS.ViewModels.AnnounceViewModel>
@{
    Layout = null;
}
    @Styles.Render("~/Content/css", "~/Content/themes/base/css")
    @Scripts.Render("~/bundles/jquery", "~/bundles/jqueryui", "~/bundles/jqueryval", "~/bundles/modernizr", "~/bundles/AdminUI", "~/bundles/jqGrid")

<div id="pageTitle" style="display:none;">公告管理</div>
<table id="gridMain"></table>
<div id="pager"></div>

<script type="text/javascript">
    $(function () {
    //var tc = @(ViewBag.TabCounter);
    var Delete=function(pid)
        {
            if(confirm("你确定要删除吗？"))
            {
                $.post("/Announce/AnnounceDelete/?tc="+tc, { id: pid },
                function (data, textStatus) {
                    $("#tabs-" + tc +" #gridMain").trigger("reloadGrid");
                });
            }
        };
        $("#tabs-" + tc +" #gridMain").jqGrid({
            url: '/Admin/Announce/JsonAnnounceList/',
            mtype: 'post',
            datatype: "json",
            colNames: ['ID', '标题','外', '效','顶','发布时间',"操作"],
            colModel: [
   		{ name: 'AnnounceId', index: 'AnnounceId', width: 80,align: 'center',sortable:false },
   		{ name: 'Title', index: 'Title', width: 80,align: 'center',sortable:false },
   		{ name: 'IsLink', index: 'IsLink', width: 80,align: 'center',sortable:false },
        { name: 'IsPass', index: 'IsPass', width: 80,align: 'center',formatter:'checkbox',sortable:false },
        { name: 'IsTop', index: 'IsTop', width: 80,align: 'center',formatter:'checkbox',sortable:false },
        { name: 'CreateTime', index: 'CreateTime', width: 100,align: 'center',sortable:false },
        { name: 'act', index: 'act', width: 80,align: 'center',sortable:false }
   	],
            rowNum: 10,
            //rowList: [10, 20, 30],
            pager: '#tabs-' + tc +' #pager',
            sortname: 'UserId',
            viewrecords: true,
            height: 'auto',
            sortorder: "desc",
            caption: "管理员列表",
            gridComplete: function () {
                var ids = $("#tabs-" + tc +" #gridMain").jqGrid('getDataIDs');
                for (var i = 0; i < ids.length; i++) {
                    var cl = ids[i];
                    modify = "<a href='#' class='Modify' onclick='GetPage(\"/Admin/AdminForm/\","+tc+",\""+cl+"\")'>修改</a>";
                    del = "<a href='#' class='Delete'>删除</a>";
                    $("#tabs-" + tc +" #gridMain").jqGrid('setRowData', ids[i], { act: modify+" "+del });

                } 
                $("#tabs-" + tc +" #gridMain" + " .Delete").click(function(){Delete($(this).closest("tr").attr("id"))});
            }
        });
        jQuery("#tabs-" + tc +" #gridMain").jqGrid('navGrid','#tabs-' + tc +' #gridMain',{edit:false,add:false,del:false});

        

    });
</script>